<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        //阶乘
        function jiecheng(e){
            if(!(e>0&&Math.floor(e))){
                return NaN
            }
            var result = 1
            for(var i=1;i<=e;i++){
                result = result*i
            }
            return result
            
        }
       var m = jiecheng(3)
       console.log(m)

       //质数
       function zhishu(e){
           if(e<2){
               return false
           }
           if(e==2){
               return true
           }
           for(var i=2;i<e;i++){
               if(e%i==0){
                   return false
               }
           }
           return true
       }
       var z = zhishu(8)
       console.log(z)

       //斐波那契数列

       function feibonaci(e){
           if(e<3){
               return e
           }
            var n1 = 1
            var n2 = 2
           for(var i=3;i<=e;i++){
            var n1 = n2
            var n2 = n1+n2
           }
           return n2
       }
       var f = feibonaci(4)
       console.log(f)
    </script>
</body>
</html>